import request from '@/util/request'

export function getShopNumber() {
  return request({
    url: 'shopping-cart/number.json',
    method: 'GET',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function listSpu(data) {
  return request({
    url: 'shopping-cart/listSpu.json',
    method: 'POST',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function getShopAmount(spuRepositoryId) {
  return request({
    url: `shopping-cart/${spuRepositoryId}.json`,
    method: 'GET',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function addCart(data) {
  return request({
    url: 'shopping-cart.json',
    method: 'POST',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function list(index) {
  return request({
    url: `shopping-cart/list/${index}.json`,
    method: 'GET',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function freight(data) {
  return request({
    url: 'shopping-cart/freight.json',
    method: 'POST',
    data,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function deletes(ids) {
  return request({
    url: `shopping-cart/${ids}.json`,
    method: 'DELETE',
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function address(params) {
  return request({
    url: 'shopping-cart/address.json',
    method: 'PATCH',
    params,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}

export function amount(params, deviation) {
  return request({
    url: `shopping-cart/amount/${deviation}.json`,
    method: 'PATCH',
    params,
    baseURL: process.env.VUE_APP_AJS_MALL
  })
}
